const toPromise = f => {
    return (params = {}) => {
      return new Promise((resolve, reject) => {
        const s = Object.assign(params, {
          success: v => resolve(v),
          fail: e => reject(e)
        });
        f(s)
      })
    }
  },
  px2rpx = function (n) {
    const {
      screenWidth: t
    } = wx.getSystemInfoSync();
    return 750 / t * n
  };

const convertTocastString=(casts)=>{
  let castsjoin="";
  for (const idx in casts) {
   castsjoin=castsjoin+casts[idx].name+"/"
  }
  return castsjoin.substring(0,castsjoin.length-1) //去掉最后一位的斜线
}
const convertTocastInfos=(casts)=>{
  let castsArray=[];
  for (const idx in casts) {
   let cast={
     img:casts[idx].avatars?casts[idx].avatars.large:"",
     name:casts[idx].name
   }
   castsArray.push(cast)
  }
  return castsArray
}

export {
  toPromise,
  px2rpx,
  convertTocastString,
  convertTocastInfos
};